package com.biz.primus.management.promotion.init;

import com.biz.primus.base.enums.CommonStatus;
import com.biz.primus.model.sso.auth.vo.GrantedAuthority;
import com.biz.primus.model.sso.auth.vo.MenuGroupVO;
import com.biz.primus.model.sso.auth.vo.MenuItemVO;
import java.util.List;
import javax.annotation.PostConstruct;
import org.springframework.stereotype.Component;

import static com.google.common.collect.Lists.newArrayList;

/**
 * @author david-liu
 */
@Component
public class StartUpService {

    @PostConstruct
    public void startUp() {
        List<MenuGroupVO> menuGroups = newArrayList();
        MenuGroupVO menuGroupVO = new MenuGroupVO("MANAGEMENT_PROMOTION", "营销管理", "营销管理页面", "fa fa-gear", CommonStatus.ENABLE, 999);
        List<MenuItemVO> menuItems = newArrayList();
        MenuItemVO specialOfferMenu = new MenuItemVO("MANAGEMENT_PROMOTION_SPECIAL_OFFER", "简单特价管理", "简单特价管理", "fa fa-list", "management/specialOffer/list.do", CommonStatus.ENABLE, 1);
        MenuItemVO userFirstOrderMenu = new MenuItemVO("MANAGEMENT_PROMOTION_USRE_FIRST_ORDER", "首单立减管理", "首单立减管理", "fa fa-list", "management/userFirstOrderCutPromotion/list.do", CommonStatus.ENABLE, 2);
        specialOfferMenu.setGrantedAuthority(new GrantedAuthority("ROLE_CAT;OPT_CAT_LIST"));
        userFirstOrderMenu.setGrantedAuthority(new GrantedAuthority("ROLE_CAT;OPT_CAT_LIST"));
        //        List<ResourceVO> resources = newArrayList();
        //        resources.add(new ResourceVO("MANAGEMENT_DEMO_CAT_EDIT", "修改", "修改猫", CommonStatus.ENABLE, new GrantedAuthority("OPT_CAT_EDIT"), 1));
        //        resources.add(new ResourceVO("MANAGEMENT_DEMO_CAT_DELETE", "删除", "删除猫", CommonStatus.ENABLE, new GrantedAuthority("OPT_CAT_DELETE"), 2));
        //        menuManageMenuItemVO.setResources(resources);
        menuItems.add(specialOfferMenu);
        menuItems.add(userFirstOrderMenu);
        menuGroupVO.setMenuItems(menuItems);
        MenuGroupVO menuGroupVO1 = new MenuGroupVO("MANAGEMENT_ACTIVITY", "活动管理", "活动管理页面", "fa fa-gear", CommonStatus.ENABLE, 998);
        List<MenuItemVO> menuItems1 = newArrayList();
        MenuItemVO activityMenuItem = new MenuItemVO("MANAGEMENT_ACTIVITY_LIST", "活动列表", "活动列表", "fa fa-list", "management/activity/new.do", CommonStatus.ENABLE, 1);
        activityMenuItem.setGrantedAuthority(new GrantedAuthority("ROLE_CAT;OPT_CAT_LIST"));
        menuItems1.add(activityMenuItem);
        menuGroupVO1.setMenuItems(menuItems1);
        menuGroups.add(menuGroupVO);
        menuGroups.add(menuGroupVO1);
//        AuthorityHyena.registerMenu(menuGroups);
    }

}
